
<html>
<head>
<style>
<!--
body {
font-family: 'lucida console',courier new, courier;
font-size: 7pt;
background: #000000;
color: #000000;
}
-->
</style>
</head>
<body>
<font color="#000000"><?




function imagegetdims($path) { 
	
	// get file and folder name
	 $v = split ("/",$path);
	 $file  =$v[count($v)-1];
	 $folder=$v[count($v)-2];
	 $cachename = "cache/".$folder."/".$file."_cache.JPG";
	if (file_exists($cachename)) {
	    $sz = getimagesize($cachename); 
	} else {
	    $sz = getimagesize($path); 
	}
	 return $sz;
}

function imagecreatefromfile($path) {
  //  $filetype = exif_imagetype($path);
  
	/* DEBUG DATA addmetric ("reading path ".$path); */
	
	// get file and folder name
	 $v = split ("/",$path);
	 $file  =$v[count($v)-1];
	 $folder=$v[count($v)-2];
	 $cachename = "cache/".$folder."/".$file."_cache.JPG";
	 
	// check to see if a cached image exists
	if (file_exists($cachename)) {
	   /* DEBUG DATA addmetric ("opening cached image");*/ 
	    $ri = imagecreatefromjpeg($cachename); 
	   /* DEBUG DATA  addmetric ("cached image open");*/
	
	} else { 
	
	   /* DEBUG DATA addmetric ("opening new image");*/ 
		if (strpos(strtolower($path),".jpg")>0) {
			 $ri = imagecreatefromjpeg($path);
		} else if (strpos(strtolower($path),".png")>0) {
			$ri = imagecreatefrompng($path);
		} else if (strpos(strtolower($path),".gif")>0) {
			 $ri = imagecreatefromgif($path);
		} else { 
		   $ri = imagecreate(100,100); 
		   $wc = imagecolorallocate($ri, 250, 250, 250); 
		   $bc = imagecolorallocate($ri, 66, 99, 250); 
		   imagestring( $ri,3, 6, 6,"FILETYPE NOT SUPPORTED!",$bc);    
		}
		
		// if this is a remote file, cache the image
		if (strpos($path,"ttp:")>0) { 
			 
	   /* DEBUG DATA addmetric ("caching http image"); */
				// create a folder if there isnt one
				 if (!is_dir("cache/".$folder)) mkdir ("cache/".$folder);  
				imagejpeg($ri,$cachename,100);
			  
		}
		
	}
	
	
	return $ri;
}




$d=$_GET["d"];
if ($d=="") $d="C:/MyFiles/IMAG0086.JPEG";
// $im = imagecreatefromjpeg($d);
$im = imagecreatefromfile($d);
$c=0;
$lastcolor=0;

list($iw,$ih) = imagegetdims($d);
$nw = 132;
$ratio = $iw/$ih;  
$nh    = $nw/$ratio; // resize by width
 
$tmp = imagecreatetruecolor($nw,$nh);

imagecopyresized($tmp,$im,0,0,0,0,$nw,$nh,$iw,$ih);



for($y=0;$y<$ih;$y+=1)
{
  for($x=0;$x<$iw;$x+=1)
  {
   $pixel = ImageColorAt($tmp, $x, $y);
   if($lastcolor != $pixel)
   { 
     printf('</font><font color="#%06x">', $pixel);
     $lastcolor = $pixel;
   } 
   echo "@";
  }
  echo "<br />\n\n<!----------------".$x.",".$y."--------------->\n\n";
}

imagedestroy ($im);
imagedestroy ($tmp);
 


exit;

$image = imagecreatefromjpeg($_GET["p"]);
print "<table border=0 cellpadding=0 cellspacing=0><tr>";
$xdim = imagesx($image);
$ydim = imagesy($image);
$pixels=0;
for ($y = 1; $y <= $ydim-1; $y+=12) {
for ($x = 1; $x <= $xdim-1; $x+=12) {
$rgb = imagecolorat($image, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
print "<td width=\"1\" height=\"1\" style=\"background-color: rgb($r, $g, $b);\"></td>";
$pixels++;
}
print "</tr><tr>";
}
print "</tr></table>";

print $pixels." pixels";



$d="C:/MyFiles/135976688.jpg";
$d="C:/MyFiles/135918696.jpg";
$d="C:/MyFiles/135944792.jpg";
$d="C:/MyFiles/anisleep.jpg";
$d="C:/MyFiles/135854096.jpg";
$d="C:\Documents and Settings\Milton Jones\My Documents\My Pictures\00000.jpg";
$d="C:/MyFiles/.Uriah..jpg";

$im = imagecreatefromjpeg($d);
//$im = imagecreatefrompng($d);
$wg = imagecolorallocate($im,255, 255, 255);   
$bg = imagecolorallocate($im, 0, 0, 0);   
 
	$rg = imagecolorallocate($im, 0, 0, 255);
	$gg = imagecolorallocate($im, 0, 255, 0);
	$ng = imagecolorallocate($im, 255, 0, 0);
	$yg = imagecolorallocate($im, 255, 255, 0);
$col = imagecolorat ($im,66,66 );

$none=0;
$limit=0;
$ret=array(); 
$rt2=array(); 
$tst=array(); 
$pts="";
$kp=0;
$mmr=0;$mmg=0;$mmb=0;
$final=array();

$dirs  =array("0,-1","1,0","1,-1","1,1","0,1","-1,1","-1,0","-1,-1");
$fact  = 4;


function wandex ($im,$x,$y,$m,$a) {
    global $ret;
	global $fact;
	global $dirs;
	global $limit;
	
    $limit ++;
	
	$bg = imagecolorallocate($im, 255, 255, 255);
	$rg = imagecolorallocate($im, 255, 0, 0);
	$gg = imagecolorallocate($im, 0, 255, 0);
	$yg = imagecolorallocate($im, 255, 255, 0);
	$pg = imagecolorallocate($im, 0, 255, 255);
	imagesetpixel ( $im, $x,$y, $pg );
	if ($limit < 500) {  
		$region=array(0,0,132,132);
		$ke = "K".$x."X".$y;
		
		 
		$compare = imagecolorat ($im,$x,$y);
		
		if ((inRegion($x,$y,$region)==1)&&($compare==$m)) { 
		
			 if (!array_key_exists($ke, $ret)) {  
			   imagesetpixel ( $im, $x,$y, $gg );
			} else {
			   imagesetpixel ( $im, $x,$y, $bg );
			}
		} 
		
		for ($e=0;$e<count($dirs);$e++) {
			$co = split(',', $dirs[$e]);
			$nx = $x+floor($co[0]*$fact);
			$ny = $y+floor($co[1]*$fact);  
			$k2 = "K".$nx."X".$ny;
			 if (!array_key_exists($k2, $ret))
			    wand ($im,$nx,$ny,$m,array($x,$y));
			 // imagesetpixel ( $im, $nx,$ny, $yg );
		}
		
		
		$ret[$ke]=array($x,$y);
		 return $ret;
	} else return 0;
}


function wand($im,$x,$y,$m,$r,$a,$loc="") {
    global $limit;
    global $ret;
    global $rt2;
    global $pts;
    global $none;
	global $kp;
	global $mmr;
	global $mmg;
	global $mmb;
	global $dirs;
	global $fact; 
	global $final; 
	$limit++;
	$bg = imagecolorallocate($im, 255, 255, 255);
	$rg = imagecolorallocate($im, 0, 0, 255);
	$gg = imagecolorallocate($im, 0, 255, 0);
	$ng = imagecolorallocate($im, 255, 0, 0);
	$yg = imagecolorallocate($im, 255, 255, 0);
	$region=array(0,0,132,132);
	$ke = "K".$x."X".$y;
	$ret[$ke]=array($x,$y);
	// imagesetpixel ( $im, $x,$y, $bg );
	// imageline($im,$x,$y,$a[0],$a[1],$yg);
	$b=0;
	
	if ($limit < 1000) { 
		// $dirs =array("0,-1","1,-1","1,0","1,1","0,1","-1,1","-1,0","-1,-1");
		// $dirs =array("0,-1","1,0","0,1","-1,0");
		// $dirs =array("1,-1","1,1","1,1","-1,1");
		// $dirs =array("4,-4","4,4","4,4","-4,4");
		
		$ttls  =array("N","NE","E","SE","S","SW","W","NW");
		 
		$test=array();
		$ktst=0;
		for ($e=0;$e<count($dirs);$e++) {
			$co = split(',', $dirs[$e]);
			$nx = $x+floor($co[0]*$fact);
			$ny = $y+floor($co[1]*$fact);
			$ck = imagecolorat ($im,$nx,$ny);
			$ke = "K".$nx."X".$ny;
			 
			
			if ((inRegion($nx,$ny,$region)==1)&&($ck==$m)) {
				    
					  
					
					    
					
					
				 if ($mmr>255) $mmr=0;
				 if ($mmg>255) $mmg=0;
				 if ($mmb>255) $mmb=0;
					
				if (!array_key_exists($ke, $ret)) { 
					$mmr++;
					$mmg++;
					$mmb++;
					$mg = imagecolorallocate($im, 255-$mmr, 255-$mmg, 255-$mmb);
					 $ret[$ke]=array($nx,$ny);  
					 $w = wand($im,$nx,$ny,$m,$r,array($nx,$ny),$ttls[$e]); 
					imagesetpixel ( $im, $nx,$ny, $mg ); 
					$final[count($final)] = $nx.".".$ny;
				} 
				$b++;  
				 
				   

					
			} else if (!array_key_exists($ke, $ret)) {  
			
				if ($nx<0) $nx=0;
				if ($ny<0) $ny=0;
				if ($a[0]<0) $a[0]=0;
				if ($a[1]<0) $a[1]=0;
				
				if ($nx>imagesx($im)-2) $nx=imagesx($im)-2;
				if ($ny>imagesy($im)-2) $ny=imagesy($im)-2;
				if ($a[0]>imagesx($im)-2) $a[0]=imagesx($im)-2;
				if ($a[1]>imagesy($im)-2) $a[1]=imagesy($im)-2;
				 
				$dx=($a[0]-$nx)/($a[0]-$nx);
				$dy=($a[1]-$ny)/($a[1]-$ny);
				
				if ($a[0]<$nx) $dx=-$dx;
				if ($a[1]<$ny) $dy=-$dy;
				$isok = 0;
				for ($cx=$nx;$cx!=$a[0];$cx+=$dx) {
					for ($cy=$ny;$cy!=$a[1];$cy+=$dy) {
					 
						 $c2 = imagecolorat ($im,$cx,$cy);
						 $k2 = "K".$cx."X".$cy;
						 if ($c2==$m) {
							 if (!array_key_exists($k2, $rt2)) { 
								imagefilledellipse($im,$cx,$cy,2,2,$rg);  
								$final[count($final)] = $cx.".".$cx;
								imagesetpixel ( $im, $cx,$cy, $ng );
								
								$test[count($test)] = $cx; 
								$test[count($test)] = $cy; 
					 
								$pts .= ($pts==""?"":",").$cx.",".$cy; 
								
								$kp ++;
								 $ret[$ke]=array($nx,$ny); 
								 
								 
								 $rt2[$k2]=array($cx,$cy); 
								 
								 $isok = 1;
								 break;
						     }
						 }
					}
					if ($isok==1) break;
				} 
			} 
		}
	   
	   // imagefilledpolygon($im,$test,count($test)/2,$rg);
	
		if ($b==0) $none++; // imagefilledellipse($im,$a[0]>=0?$a[0]:0,$a[1]<132?$a[1]:121,4,4,$rg);
		return $b;
		
		
		
		
	}
	
 }
 
 
function inRegion($x,$y,$region) {
    $ok = 0;
    if ($x >= $region[0]) {
        if ($x <= $region[2]) {
            if ($y >= $region[1]) {
                if ($y <= $region[3]) {
                    $ok = 1;
                }
            }
        }           
    }
    return $ok;
}

$wx=40;$wy=46;
$rgb = imagecolorat ($im,$wx,$wy );
wand ($im,$wx,$wy,$rgb,array($wx,$wy));
 imagefilledellipse($im,$wx,$wy,4,4,$gg);
$pts=split(',',$pts);
 
$hc = imagecolorallocate($im, 255, 0, 255); 
  

//imagecolorset ($im, $rgb, 255, 255, 255 );

	// imagefilltoborder($im, 66, 66,$rgb , $bg);
	
	$r = ($rgb >> 16) & 255;
	$g = ($rgb >> 8) & 255;
	$b = $rgb & 255;
	$r=base_convert($r, 10, 16);
	$b=base_convert($b, 10, 16);
	$g=base_convert($g, 10, 16);
	$c= strtoupper($r.$g.$b);
	//imagestring($im,1,80,20,$limit."/".count($final),$bg);
	
	$ke = "K".$wx."X".$wy;
	
	imagestring($im,1,20,20, $ret[$ke][0]."/".$ret[$ke][1]."/".array_key_exists("T".$ke, $ret),$bg);
	
	
		 header("Content-type: image/png");
		
		// Display and destroy the image
		imagepng($im);
		imagedestroy($im); 
		exit;
		
?>



<html>
<head>
<style>
<!--
body {
font-family: 'lucida console',courier new, courier;
font-size: 7pt;
background: #000000;
color: #000000;
}
-->
</style>
</head>
<body>
<font color="#000000"><?




/*

*/
$caption="PROPERTY OF URIAH";


?> 
</font>